<?php
	include_once("../../MasterPages/headerPHPScript.php");
	$CourseScheduleService = new CourseScheduleService();
	$CourseID = $_GET["CourseID"];
	$CourseScheduleID = ISSET($_GET["CourseScheduleID"]) ? $_GET["CourseScheduleID"] : 0;
	
	if($CourseScheduleID==0){
		$CourseScheduleDTO = new CourseScheduleDTO();
		$CourseScheduleDTO->CourseID = $CourseID;
		$CourseScheduleDTO->Date = ConvertStringToDate($_POST["dateStart"]);
		$CourseScheduleDTO->TimeStart = $_POST["timeStart"];
		$CourseScheduleDTO->TimeEnd = $_POST["timeEnd"];

		$CourseScheduleService->InsertCourseSchedule($CourseScheduleDTO);
	}else{
		$CourseScheduleService->DeleteCourseSchedule($CourseScheduleID);	
	}
	header("location:../index.php?page=teacher-manage-courseschedule.php&CourseID=$CourseID");
?>
